/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * FagAdminPanel.java
 *
 * Created on May 11, 2012, 1:04:41 AM
 */
package view;

/**
 *
 * @author Marc
 */
public class FagAdminPanel extends javax.swing.JPanel {

    /** Creates new form FagAdminPanel */
    public FagAdminPanel() {
        
       
        
        
        
        initComponents();
        
        jList2.setEnabled(false);
        jButton1.setEnabled(false);
        jButton2.setEnabled(false);
        jButton3.setEnabled(false);
        jComboBox1.setEnabled(false);
        jComboBox2.setEnabled(false);
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jScrollPane1 = new javax.swing.JScrollPane();
        jList1 = new javax.swing.JList();
        jButton2 = new javax.swing.JButton();
        jPanel1 = new javax.swing.JPanel();
        jLabel4 = new javax.swing.JLabel();
        jTextField1 = new javax.swing.JTextField();
        jLabel5 = new javax.swing.JLabel();
        jButton3 = new javax.swing.JButton();
        jLabel6 = new javax.swing.JLabel();
        jComboBox1 = new javax.swing.JComboBox();
        jComboBox2 = new javax.swing.JComboBox();
        jLabel3 = new javax.swing.JLabel();
        jComboBox3 = new javax.swing.JComboBox();
        jLabel2 = new javax.swing.JLabel();
        jComboBox4 = new javax.swing.JComboBox();
        jLabel7 = new javax.swing.JLabel();
        jScrollPane2 = new javax.swing.JScrollPane();
        jList2 = new javax.swing.JList();
        jButton1 = new javax.swing.JButton();
        jButton4 = new javax.swing.JButton();

        setLayout(null);

        jLabel1.setText("Tilgængelige Fag:");
        add(jLabel1);
        jLabel1.setBounds(300, 80, 100, 14);

        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        jList1.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "DanskH0001", "DanskH0002", "EngelskH0001", "TyskH0001", "TyskH0002", "MatematikH0001", "MatematikH0002", "MatematikH0004", "MatematikH0005" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jList1.addListSelectionListener(new javax.swing.event.ListSelectionListener() {
            public void valueChanged(javax.swing.event.ListSelectionEvent evt) {
                jList1ValueChanged(evt);
            }
        });
        jScrollPane1.setViewportView(jList1);

        add(jScrollPane1);
        jScrollPane1.setBounds(300, 100, 159, 320);

        jButton2.setText("Slet fag");
        add(jButton2);
        jButton2.setBounds(330, 430, 100, 30);

        jPanel1.setBorder(javax.swing.BorderFactory.createTitledBorder(javax.swing.BorderFactory.createEtchedBorder(), "Opret nyt fag"));
        jPanel1.setLayout(null);

        jLabel4.setText("ID:");
        jPanel1.add(jLabel4);
        jLabel4.setBounds(40, 60, 15, 14);

        jTextField1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextField1ActionPerformed(evt);
            }
        });
        jPanel1.add(jTextField1);
        jTextField1.setBounds(80, 60, 108, 20);

        jLabel5.setText("Lærer:");
        jPanel1.add(jLabel5);
        jLabel5.setBounds(30, 140, 70, 14);

        jButton3.setText("Opret fag");
        jButton3.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton3ActionPerformed(evt);
            }
        });
        jPanel1.add(jButton3);
        jButton3.setBounds(80, 230, 120, 40);

        jLabel6.setText("Klassetrin:");
        jPanel1.add(jLabel6);
        jLabel6.setBounds(10, 100, 50, 14);

        jComboBox1.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Vælg Årgang", "0. Klasse", "1. Klasse", "2. Klasse", "3. Klasse", "4. Klasse", "5. Klasse", "6. Klasse", "7. Klasse", "8. Klasse", "9. Klasse", "10 . Klasse" }));
        jComboBox1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox1ActionPerformed(evt);
            }
        });
        jPanel1.add(jComboBox1);
        jComboBox1.setBounds(80, 100, 110, 20);

        jComboBox2.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Vælg Lærer", "Jens Peter", "Hans Ole" }));
        jComboBox2.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jComboBox2ActionPerformed(evt);
            }
        });
        jPanel1.add(jComboBox2);
        jComboBox2.setBounds(80, 140, 150, 20);

        jLabel3.setText("Trindeling:");
        jPanel1.add(jLabel3);
        jLabel3.setBounds(10, 180, 70, 14);

        jComboBox3.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Vælg Niveau", "3-delt", "10-delt" }));
        jPanel1.add(jComboBox3);
        jComboBox3.setBounds(80, 180, 110, 20);

        add(jPanel1);
        jPanel1.setBounds(700, 60, 280, 300);
        jPanel1.getAccessibleContext().setAccessibleName("Opret nyt fag");

        jLabel2.setText("Hold:");
        add(jLabel2);
        jLabel2.setBounds(20, 20, 25, 14);

        jComboBox4.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
        add(jComboBox4);
        jComboBox4.setBounds(20, 40, 100, 20);

        jLabel7.setText("Holdets Fag:");
        add(jLabel7);
        jLabel7.setBounds(20, 80, 90, 14);

        jList2.setModel(new javax.swing.AbstractListModel() {
            String[] strings = { "Item 1", "Item 2", "Item 3", "Item 4", "Item 5" };
            public int getSize() { return strings.length; }
            public Object getElementAt(int i) { return strings[i]; }
        });
        jScrollPane2.setViewportView(jList2);

        add(jScrollPane2);
        jScrollPane2.setBounds(20, 100, 150, 320);

        jButton1.setText(" Tilføj Fag");
        add(jButton1);
        jButton1.setBounds(180, 200, 110, 23);

        jButton4.setText("Fjern Fag");
        add(jButton4);
        jButton4.setBounds(180, 250, 110, 23);
    }// </editor-fold>//GEN-END:initComponents

    private void jTextField1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextField1ActionPerformed
        if(!jTextField1.getText().equalsIgnoreCase("")){
            jComboBox1.setEnabled(true);
        }
    }//GEN-LAST:event_jTextField1ActionPerformed

    private void jComboBox1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox1ActionPerformed
        if(jComboBox1.getSelectedIndex() != 0){
            jComboBox2.setEnabled(true);
        }
    }//GEN-LAST:event_jComboBox1ActionPerformed

    private void jComboBox2ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jComboBox2ActionPerformed
        if(jComboBox1.getSelectedIndex() != 0){
            jButton3.setEnabled(true);
        }
    }//GEN-LAST:event_jComboBox2ActionPerformed

    private void jList1ValueChanged(javax.swing.event.ListSelectionEvent evt) {//GEN-FIRST:event_jList1ValueChanged
        jButton2.setEnabled(true);
        jList2.setEnabled(true);
        
    }//GEN-LAST:event_jList1ValueChanged

    private void jButton3ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton3ActionPerformed
        
        
        
        // Efter fag er gemt
        jTextField1.setText("");
        jTextField1.setEnabled(false);
        jComboBox1.setEnabled(false);
        jComboBox2.setEnabled(false);
    }//GEN-LAST:event_jButton3ActionPerformed

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton jButton1;
    private javax.swing.JButton jButton2;
    private javax.swing.JButton jButton3;
    private javax.swing.JButton jButton4;
    private javax.swing.JComboBox jComboBox1;
    private javax.swing.JComboBox jComboBox2;
    private javax.swing.JComboBox jComboBox3;
    private javax.swing.JComboBox jComboBox4;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JList jList1;
    private javax.swing.JList jList2;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane2;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration//GEN-END:variables
}
